package com.qianyu.project.mapper.provider.mfy;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.qianyu.project.entity.DeviceRequirePlan;
import org.apache.ibatis.jdbc.SQL;
import org.springframework.util.StringUtils;

import java.util.Map;

/**
 * @Author mfy
 * @desc
 */
public class DeviceOilUsedProvider {
    public String Mylist(IPage<DeviceRequirePlan> page, Map<String, String> params){
        return new SQL(){
            {
                SELECT("*");
                FROM("device_oil_used dou,system_user su,project_info pi");
                WHERE("dou.fill_user=su.id and dou.p_id=pi.id");
                if(!StringUtils.isEmpty(params.get("approveStatus"))){
                    WHERE("dou.approve_status = '"+params.get("approveStatus")+"'");
                }
                if(!StringUtils.isEmpty(params.get("startdate"))){
                    WHERE("dou.startdate <= '"+params.get("startdate")+"'");
                }
                if(!StringUtils.isEmpty(params.get("enddate"))){
                    WHERE("dou.enddate >= '"+params.get("enddate")+"'");
                }

            }
        }.toString();
    }

    public String listNopage(Map<String, String> params){
        return new SQL(){
            {
                SELECT("*");
                FROM("device_oil_used dou,system_user su,project_info pi");
                WHERE("dou.fill_user=su.id and dou.p_id=pi.id");
                if(!StringUtils.isEmpty(params.get("approveStatus"))){
                    WHERE("dou.approve_status = '"+params.get("approveStatus")+"'");
                }
                if(!StringUtils.isEmpty(params.get("startdate"))){
                    WHERE("dou.startdate <= '"+params.get("startdate")+"'");
                }
                if(!StringUtils.isEmpty(params.get("enddate"))){
                    WHERE("dou.enddate >= '"+params.get("enddate")+"'");
                }
            }
        }.toString();
    }
}
